<?php

namespace app\common\model\platform;

use app\common\cache\ConfigCache;
use fast\Random;
use think\Model;


class Plat extends Model
{

    // 表名
    protected $name = 'platform';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];

    protected static function init()
    {
        Plat::afterInsert(function ($plat) {
            //插入该平台默认参数
            ConfigCache::instance($plat->id)->insert();
            //生成key
            $key = Random::alnum(20);
            $plat->key = $key;
            $plat->save();
        });
    }

    







}
